home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include "gl/image.h"
-
- #define Pack(r,g,b,a) ((int)(r) | ((int)(g) << 8) | ((int)(b) << 16) | ((int)(a) << 24))
-
- unsigned long *
- readImageRGB(name, w, h)
- char * name;
- int *w, *h;
- {
- unsigned long *image;
- IMAGE *image_in;
- int row, components;
- unsigned long *scan;
-
- if ( (image_in = iopen(name, "r")) == NULL) {
- return 0;
- }
-
- *w = image_in->xsize;
- *h = image_in->ysize;
- components = image_in->zsize;
-
- if (components != 3)
- return 0;
-
- image = (unsigned long *)malloc(sizeof(unsigned long) * *w * *h);
-
- scan = image;
-
- for (row = 0; row < *h; row++) {
- short rowbuff[3][4096];
- int i;
-
- getrow(image_in, rowbuff[0], row, 0);
- getrow(image_in, rowbuff[1], row, 1);
- getrow(image_in, rowbuff[2], row, 2);
- for (i = 0; i < *w; i++)
- *(scan++) =
- Pack(rowbuff[0][i], rowbuff[1][i], rowbuff[2][i], 0);
- }
-
- iclose(image_in);
- return image;
- }
-